<%@ page import="java.sql.Connection" %>
<%@ page import="javax.swing.plaf.nimbus.State" %>
<%@ page import="java.sql.Statement" %>
<%@ page import="java.sql.DriverManager" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: lenovo
  Date: 2018/4/3
  Time: 0:15
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>显示所有信息</title>
</head>
<body>
<style type="text/css">
    table{
        border: 1px solid #000;
        border-collapse: collapse;
    }

    td,th{
        border: 1px solid #000;
        padding: 10px;
    }


</style>
<table>
    <thead>
    <tr>
        <th>编号</th>
        <th>用户名</th>
        <th>密码</th>
        <th>管理</th>
    </tr>
    </thead>
    <a href="userSelect.jsp">用户查询</a>
    <%

        Connection connection=null;
        Statement statement=null;
        ResultSet resultSet=null;
        String sql="select* from t_users";

        Class.forName("com.mysql.jdbc.Driver");
        connection= DriverManager.getConnection(
                "jdbc:mysql://localhost:3306/sctu_javaweb_2018?serverTimezone=UTC&& characterEncoding = UTF-8",
                "root",
                "123456");
        statement=connection.createStatement();
        resultSet=statement.executeQuery(sql);
        while (resultSet.next()) {
            int id=resultSet.getInt(1);

//                 out.print("<p>" + resultSet.getInt(1) + "           " + resultSet.getString(2) + "        " + resultSet.getString(3) + "   " +
//                    "<a href='userUpdate.jsp?id=" + resultSet.getInt(1) + "&name=" + resultSet.getString(2) + "&password=" + resultSet.getString(3) + "' >更新</a>" + "     " +
//                    "<a href='userDelete.jsp?id=" + resultSet.getInt(1) + "'>删除</a></p>");

    %>



//art+f1 会出现Project View
//    ResultSet resultSet=statement.executeQuery("SELECT *FROM t_users");
//    out.write("<p>"+"编号"+"用户名"+"密码"+"</p>");
//    while (resultSet.next()){
//        out.write("<p>"+resultSet.getInt(1)+" "+resultSet.getString(2)+" "+resultSet.getString(3)+"</p>");


    %>
    <tr>
        <td><%=resultSet.getInt("id")%></td>
        <td><%=resultSet.getString("userName")%></td>
        <td><%=resultSet.getString("password")%></td>
        <td><a href="userEdit.jsp?id=<%=id%>">更新</a>&nbsp;&nbsp;
            <a href="userDelete.jsp?id=<%=id%>">删除</a></td>
    </tr>

    <%
        }
    connection.close();
    statement.close();
    resultSet.close();
    %>
</table>
<%--<%@include file="footer.jsp" %>--%>
<jsp:include page="footer.jsp">
    <jsp:param name="year" value="2018"></jsp:param>
</jsp:include>
</body>
</html>
